/**
 * Author: luoqi
 * Created Date: 2025-11-12 01:09:24
 * Last Modified: 2025-11-15 02:44:18
 * Modified By: luoqi at <**@****>
 * Copyright (c) 2025 <*****>
 * Description:
 */

#ifndef _TIM_PORT_H_
#define _TIM_PORT_H_

#include <stdint.h>

typedef enum {
    TIM_PORT_PWM1,
    TIM_PORT_ENC2,
    TIM_PORT_ENC3,
    TIM_PORT_TIM4,
} TimPort;

typedef enum {
    PWM_CH1 = 1,
    PWM_CH2 = 2,
    PWM_CH3 = 3,
    PWM_CH4 = 4,
} PwmChannel;

typedef struct {
    int overflow;
    uint16_t count;
} TimVal;

int tim_start(TimPort port);

int tim_stop(TimPort port);

int tim_pwm_set(TimPort port, PwmChannel ch, uint16_t duty);

int tim_get(TimPort port, TimVal *val); 

void tim4_set_it_period(uint32_t us);

void tim4_it_cb_overide(void);

#endif
